/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*   File:      AGV_Function_Selection.cpp
*   Author:    刘洋兵
*   Function:  下拉选择界面，选择显示对应的数据库表操作界面
*   Time:      2025-09-09
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#include "AGV_Function_Selection.h"
#include "ui_AGV_Function_Selection.h"

AGV_Function_Selection::AGV_Function_Selection(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::AGV_Function_Selection)
{
    ui->setupUi(this);
    //ui->treeWidget->expandAll();

    QTreeWidgetItem *item = ui->treeWidget->topLevelItem(0);
    QTreeWidgetItem *item1 = ui->treeWidget->topLevelItem(1);
    if (item && item1) {
        item->setExpanded(true);
        item1->setExpanded(true);
    }

}

AGV_Function_Selection::~AGV_Function_Selection()
{
    delete ui;
}

/**
 * @brief  treeWidget控件点击显示指定界面
 * @param  item  treeWidget控件单个项的对象指针
 * @param  column item的文本索引
 */
void AGV_Function_Selection::on_treeWidget_itemClicked(QTreeWidgetItem *item, const int& column)
{
    QString text = item->text(column);
    if(text == "车辆管理"){
        emit send_window_number(0,0);
    }
    if(text == "新车加入"){
        emit send_window_number(0,0);
        emit sendnewAGV();
    }
    if(text == "车辆信息表"){
        emit send_window_number(0,0);
    }
    else if(text == "车辆状态表")
    {
        emit send_window_number(0,1);
    }
    else if(text == "告警信息配置")
    {
        emit send_window_number(1,0);
    }
    else if(text == "地图配置管理")
    {
        emit send_window_number(2,0);
    }
    else if(text == "地图信息表")
    {
        emit send_window_number(2,0);
    }
    else if(text == "区域站点表")
    {
        emit send_window_number(2,1);
    }
    else if(text == "车辆站点表")
    {
        emit send_window_number(2,2);
    }
    else if(text == "车载路径表")
    {
        emit send_window_number(2,3);
    }
    else if(text == "避障策略管理")
    {
        emit send_window_number(3,0);
    }
    else if(text == "AGV前方避障策略")
    {
        emit send_window_number(3,0);
    }
    else if(text == "AGV后方避障策略")
    {
        emit send_window_number(3,1);
    }
    else if(text == "AGV左方避障策略")
    {
        emit send_window_number(3,2);
    }
    else if(text == "AGV右方避障策略")
    {
        emit send_window_number(3,3);
    }
    else if(text == "任务管理")
    {
        emit send_window_number(4,0);
    }
    else if(text == "任务表")
    {
        emit send_window_number(4,0);
    }
    else if(text == "AGV小车任务发送")
    {
        emit sendAGV_task(1,-1);
    }
    else if(text == "动作管理")
    {
        emit send_window_number(5,0);
    }
    else if(text == "动作指令表")
    {
        emit send_window_number(5,0);
    }
    else if(text == "动作组表")
    {
        emit send_window_number(5,1);
    }

}
